<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Flask Course and Assignment Search</title>
</head>
<body>
    <h1>Search Courses and Assignments</h1>
    <form method="post" >
        <label for="search_field">Search Field:</label>
        <select name="search_field" id="search_field">
            <option value="CName" {% if search_field == 'CName' %}selected{% endif %}>Course Name</option>
            <option value="CCategory" {% if search_field == 'CCategory' %}selected{% endif %}>Course Category</option>
            <option value="CNumber" {% if search_field == 'CNumber' %}selected{% endif %}>Course Number</option>
            <option value="Score" {% if search_field == 'Score' %}selected{% endif %}>Score</option>
        </select>
        <br>
        <label for="search_value">Search Value:</label>
        <input type="text" name="search_value" id="search_value" value="{{ search_value }}">
        <br>
        <input type="submit" value="Search">
    </form>

    {% if results is not none %}
        <h2>Results:</h2>
        {% if results %}
            <table border="1">
                <thead>
                    <tr>
                        <th>A_id</th>
                        <th>Q_id</th>
                        <th>Course Name</th>
                        <th>Course Number</th>
                        <th>Course Category</th>
                        <th>Q_text</th>
                        <th>LLM Name</th>
                        <th>LLM Answer</th>
                        <th>Score</th>
                    </tr>
                </thead>
                <tbody>
                    {% for item in results %}
                    <tr>
                        <td>{{ item.A_id }}</td>
                        <td>{{ item.Q_id }}</td>
                        <td>{{ item.course_name }}</td>
                        <td>{{ item.course_number }}</td>
                        <td>{{ item.course_category }}</td>
                        <td>{{ item.Q_text }}</td>
                        <td>{{ item.LLM_name }}</td>
                        <td>{{ item.LLM_answer }}</td>
                        <td>{{ item.score }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% else %}
            <p>No results found.</p>
        {% endif %}
    {% endif %}
</body>
</html>
